package Game.Items.Armors.Chestplates;

import org.newdawn.slick.Graphics;
import org.newdawn.slick.geom.Vector2f;

import Game.GameHelper;
import Game.Items.GameItem;
import Game.Objects.GOPlayer;
import Game.Objects.Creatures.GOCreature;
import Tools.Drawing.FontTagSystem;

/** Bone Chestplate class
 * @author Aikidos
 */
public class GIBoneChestplate extends GameItem {

	// Stats
	private int _defense = 4;
	
	public GIBoneChestplate() {
		super("Bone Chestplate");
		
		IsEquip = true;
		Category = ECategory.Chestplate;
		
		_cost = 350;
		_weight = 6.94f;
		
		// Set defense
		_defense = GameHelper.getRandom().nextInt(_defense) + 1;
	}
	
	@Override
	public void on() { 
		if (!_isOn)
		{
			_isOn = true;
			
			if (_ownerGameObject.isCreature())
			{
				GOCreature creature = (GOCreature)_ownerGameObject;
				creature.Defense += _defense;
			}
			
			if (_ownerGameObject.isPlayer())
			{
				GOPlayer player = (GOPlayer)_ownerGameObject;
				player.Defense += _defense;
			}
		}
	}
	
	@Override
	public void off() {
		if (_isOn)
		{
			_isOn = false;
			
			if (_ownerGameObject.isCreature())
			{
				GOCreature creature = (GOCreature)_ownerGameObject;
				creature.Defense -= _defense;
			}
			
			if (_ownerGameObject.isPlayer())
			{
				GOPlayer player = (GOPlayer)_ownerGameObject;
				player.Defense -= _defense;
			}
		}
	}
	
	@Override
	public void drawInfo(Vector2f drawPos, Graphics g) {
		FontTagSystem.drawText("Description:", drawPos);
		
		drawPos.y += 20;
		
		FontTagSystem.drawText("Defence: [green]" 
				+ String.valueOf(_defense) + "[/green]", drawPos);
	}

}
